package com.gewu.bookeeping.MyDb.dao;

import android.content.Context;

import com.gewu.bookeeping.IModel.IMenyInDaoModel;
import com.gewu.bookeeping.MyDb.MyDatabase;
import com.gewu.bookeeping.MyDb.bean.WeChtBeanIn;
import com.j256.ormlite.dao.Dao;
import java.sql.SQLException;
import java.util.List;

public class WeChtDaoInPerson implements IMenyInDaoModel {

    private Dao<WeChtBeanIn,Integer> wechartdao;

    public WeChtDaoInPerson(Context context) {
        try {
            this.wechartdao = MyDatabase.getInstance(context).getDao(WeChtBeanIn.class);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    @Override
    public int add(Object weChtBeanIn) {
        int i = 0;
        try {
            i = wechartdao.create((WeChtBeanIn) weChtBeanIn);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return i;
    }

    @Override
    public int delect(int id) {
        int i = 0;
        try {
            i = wechartdao.deleteById( id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return i;
    }

    @Override
    public  List<WeChtBeanIn> quer() {
        List<WeChtBeanIn> weChtBeanIns=null;
        try {
            weChtBeanIns = wechartdao.queryForAll();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return weChtBeanIns;
    }

    @Override
    public List<WeChtBeanIn> querLike(String values) {
        List<WeChtBeanIn> time=null;
        try {
            time = wechartdao.queryForEq("time", values);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return time;
    }


}
